<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/taglib.jsp" %>
<%@page import="java.util.Date"%>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="微社区,Q生活" name="keywords"/>
<meta content="微社区,Q生活" name="description"/>
<title>微社区|Q生活</title>
<link rel="stylesheet" href="${ctx }/static/css/Master.css"/>
<script src="${ctx }/static/js/jquery-1.9.0.min.js"></script>
<script src="${ctx }/static/js/Common.js"></script>
<script type="text/javascript" src="${ctx }/static/js/jsScroller.js"></script>
<script type="text/javascript" src="${ctx }/static/js/jsScrollbar.js"></script>

<script src="${ctx}/static/plugins/layer/layer.js"></script>
<%-- 基础js,所有页面都需要引入此js,依赖layer.js --%>
<script src="${ctx}/static/js/common/base.js"></script>
<%
Date now = new Date();
String dayStr = "";
switch (now.getDay()) {
case 0:
	dayStr = "星期日";
	break;
case 1:
	dayStr = "星期一";
	break;
case 2:
	dayStr = "星期二";
	break;
case 3:
	dayStr = "星期三";
	break;
case 4:
	dayStr = "星期四";
	break;
case 5:
	dayStr = "星期五";
	break;
case 6:
	dayStr = "星期六";
	break;
case 7:
	dayStr = "星期日";
	break;
}   
%>
<script type="text/javascript">
$(function(){
	// 加载layer.ext.js
	layer.config({
	    extend: 'extend/layer.ext.js'
	});
	
	$("#mainIframe").load(function(){
		$(this).height(0); //重置高度,用于每次刷新时控制IFRAME高度初始化,不然高度会一直增加
		//右边剩下高度
		var rightHeight = $(document).outerHeight()-$("#header").outerHeight()-$(".vote").outerHeight();
		//ifram内容高度
        var height = $(this).contents().outerHeight();
        //console.log("右边剩下高度",rightHeight);
		//console.log("ifram内容高度",height);
        height =  Math.max(height,rightHeight); 
        //console.log("取最大高度",height,"减去8",height-8);
        $(this).height(height-8);
	});
	
	//用户图像提示信息
	$(".userIcon").mouseenter(function(){
		if($("#userTips").length>0){
	   		layer.tips($("#userTips").html(), this, {time: 0,tips:3});
		}
	}).mouseleave(function(){
		layer.closeAll('tips'); //关闭所有的tips层    
	});
});
function current(item,pName,name,url){
	$(".childMenu").removeClass("curr");
	$(item).parent().addClass("curr");
	
	$(".posi").html('<span class="indexIcon grayhomeIcon"></span><span><a href="${ctx}/welcome" onclick="toMenu(\'首页\');" target="mainIframe">首页</a></span> > <span>'+pName+'</span> > <span class="last"><a href="${ctx}/'+url+'"  target="mainIframe">'+name+'</a></span>');
	
	//配置动态高度的子页面,根据高度需要显示iframe内部滚动条
	//资源管理/缓存监控/在线用户监控/建议与反馈/反馈管理
	if(url == "resource/list" || url == "monitor/ehcache" || url == "monitor/online"
			|| url == "feedback/myList" || url == "feedback/syslist"){
		$("#mainIframe").attr('scrolling','auto');
	}else{
		$("#mainIframe").attr('scrolling','no');
	}
	
}

//导航栏跳转
function toMenu(str){
	//移除菜单选中样式
	$('.childMenu').removeClass('curr');
	if(str == '首页'){
		$(".posi").html('<span class="indexIcon grayhomeIcon"></span><span><a href="${ctx}/welcome" onclick="toMenu(\'首页\');" target="mainIframe">首页</a></span>');
	}else if(str == '帮助'){
		$(".posi").html('<span class="indexIcon grayhomeIcon"></span><span><a href="${ctx}/welcome" onclick="toMenu(\'首页\');" target="mainIframe">首页</a></span> > <span><a href="${ctx}/help" onclick="toMenu(\'帮助\');" target="mainIframe">帮助</a></span>');
	}else{
		$(".posi").html('<span class="indexIcon grayhomeIcon"></span><span class="last">'+str+'</span>');
	}
}

//全屏查看图片, 供iframe子页面调用
function showPhotos(item){
	if(!item){
		return;
	}
	layer.ready(function(){ //为了layer.ext.js加载完毕再执行
			item.each(function(i,item_){
				initPhotos(item_);
			});
		
	});
}

// 全屏查看图片
function initPhotos(item){
	layer.photos({
        photos: item, //在父页查看图片直接采用'.layer-photos'方式不行
		closeBtn:1
    });
}
</script>
</head>

<body>
<div class="wrapper">
	<!--头部-->
	<header id="header">
		<div class="logo">
			<span><img src="${ctx }/static/images/logo.png" alt=""/></span><img src="${ctx }/static/images/logo_t.png" alt=""/>
		</div>
		<div class="headright">
			<div class="topuser"><span class="indexIcon userIcon"></span>您好，[${diy:getCurrentUserRealName() }<%--<shiro:principal/>--%>]！  <fmt:formatDate value="<%=now %>" pattern="yyyy年MM月dd日" />  <%=dayStr %></div>
			<div id="userTips" style="display: none;">角色：${diy:getCurrentUserRoleName() }<br>群组：${diy:getCurrentUserGroupName() }</div>
			<nav class="topnav">
				<ul>
					<li><a href="${ctx}/welcome" onclick="toMenu('首页');" target="mainIframe"><span class="indexIcon homeIcon"></span>首页</a></li>
					<li><a href="${ctx}/help" onclick="toMenu('帮助');" target="mainIframe"><span class="indexIcon helpIcon"></span>帮助</a></li>
					<%--<li><a href="javascript:void(0);">
						<span class="indexIcon emailIcon"></span>邮件</a>
						<span class="tipnum">1</span>
					</li>
					--%><li><a href="${ctx}/logout"><span class="indexIcon logoutIcon"></span>退出</a></li>
				</ul>
			</nav>
		</div>
	</header>
	<!--/头部-->
	<section id="content">
	<!--左边-->
		<section class="main_left" id="Scroller-Left">
			<div class="Scroller-Container">
				<menu class="menu">
				<ul>
					<c:forEach items="${menus.childResList}" var="m" varStatus="var">
			        <li class="${m.resClass }"><a href="javascript:void(0);" >${m.resName}</a>
						<ul style="display:none;">
							<c:forEach items="${m.childResList}" var="child">
							<li class="childMenu"><a href="${ctx}/${child.resUrl}" onclick="current(this,'${m.resName}','${child.resName}','${child.resUrl}');"  target="mainIframe">${child.resName}</a></li>
							</c:forEach>
						</ul>
					</li>
				    </c:forEach>
				    
				</ul>
			</menu>
			</div>
			<div class="Scrollbar-Container" id="Scrollbar-ContainerLeft">
			  <div class="Scrollbar-Up"></div>
			  <div class="Scrollbar-Track">
				<div class="Scrollbar-Handle"></div>
			  </div>
			  <div class="Scrollbar-Down"></div>
			</div>
		</section>
		<!--/左边-->
		
		<!-- 右边 -->
		<section id="main_right">
			<article class="vote">
				<div class="posi"><span class="indexIcon grayhomeIcon"></span><span><a href="${ctx}/welcome" onclick="toMenu('首页');" target="mainIframe">首页</a></span></div>
			</article>
			<!-- <section class="boxRight"> -->
				<!-- 右侧页面内容 -->
				<iframe id="mainIframe" name="mainIframe" src="${ctx}/welcome"  width="100%" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes" ></iframe>
			<!-- </section> -->
		</section>
		<!-- /右边 -->
	
	</section>
</div>
</body>
</html>


